package com.situ.lession1226.api;

import com.situ.lession1226.model.Community;
import com.situ.lession1226.model.Rating;
import com.situ.lession1226.service.RatingService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

//对每个电影下面的评论进行展示和增加
@RestController
@RequestMapping(value = "/api/v1/ranking", produces = "application/json;charset=utf-8")
public class RankingApi {
    private RatingService RatingService;

    public RankingApi(RatingService RatingService) {
        this.RatingService = RatingService;
    }

    @GetMapping("/get")
    public Map<String,Object> get(){
        List <Rating> Rating=RatingService.findBest();

        if (Rating == null) {
            return Map.of("success", false);
        } else {
            return Map.of("success",true,"ranking",Rating);
        }

    }


}
